Skip to content

Radar plugin

joanpuigsanz edited this page Oct 12, 2014 · 5 revisions

If you want to add a radar view you could use the Radar plugin (jar & src).

For that it is required to create the RadarView, for instance with the layout file:

<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="right|top"
    android:background="@drawable/radar_bg_small" >

    <com.beyondar.android.plugin.radar.RadarView
        android:id="@+id/radarView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/radar_north_small" />
</FrameLayout>

Now it is time to get the view in our Activity and add the plugin to the World object.

public void onCreate(Bundle savedInstanceState) {
    ...
    radarView = (RadarView) findViewById(R.id.radarView);
    // Create the Radar plugin
    mRadarPlugin = new RadarWorldPlugin(contex);
    // set the radar view in to our radar plugin
    mRadarPlugin.setRadarView(mRadarView);
    // Set how far (in meters) we want to display in the view
    mRadarPlugin.setMaxDistance(100);
    // and finally let's add the plugin
    mWorld.addPlugin(mRadarPlugin);
    ...
}

Example code

You can find the source code of a complete example here.